package org.equivalence.common;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * This allows for us to store configuration properties in external properties files.
 * We can then retrieve the property by calling getProperty().
 *  
 * @author Jonathan Giles
 */
public class PropertiesReader {
	private Properties properties;
	
	public PropertiesReader(InputStream propertyFileStream) {
		properties = new Properties();
		
		try {
			properties.load(propertyFileStream);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Call this to get the value stored in the properties file, or else the default value
	 * is returned.
	 */
	public String getProperty(String key, String defaultValue) {
		return properties.getProperty(key, defaultValue);
	}
}
